<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html>

<html>
<head>
<title></title>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">

<meta http-equiv="description" content="ajax方式">

<!-- 引入bootstrap -->
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/plugin/css/bootstrap.min.css">
<!-- 引入JQuery  bootstrap.js-->
<script
	src="${pageContext.request.contextPath}/plugin/js/jquery-3.2.1.min.js"></script>
<script
	src="${pageContext.request.contextPath}/plugin/js/bootstrap.min.js"></script>
</head>
<body>
	<!-- 顶栏 -->
	<jsp:include page="top.jsp"></jsp:include>
	<!-- 中间主体 -->
	<div class="container" id="content">
		<div class="row">
			<div class="col-md-10">
				<div class="panel panel-default">
					<div class="panel-heading">
						<div class="row">
							<h1 style="text-align: center;">新增职位</h1>
						</div>
					</div>
					<div class="panel-body">
						<form class="form-horizontal" role="form" id="addform" action=""
							method="post">
							<div class="form-group">
								<label for="inputpositionName" class="col-sm-2 control-label">职位名称</label>
								<div class="col-sm-10">
									<input type="text" class="form-control" id="inputpositionName"
										name="positionName" placeholder="请输入职位名称">
								</div>
							</div>
							<div class="form-group">
								<label for="inputpositionDcription" class="col-sm-2 control-label">职位描述</label>
								<div class="col-sm-10">
									<input type="text" class="form-control"
										id="inputpositionDcription" name="positionDcription"
										placeholder="请描述一下此职位">
								</div>
							</div>
							<div class="form-group">
								<label for="inputparentId" class="col-sm-2 control-label">父职位</label>
								<div class="col-sm-10">
									<input type="text" class="form-control" id="inputparentId"
										name="parentId" placeholder="请选择父职位">
								</div>
							</div>

							<div class="form-group" style="text-align: center">
								<button id="submitId" class="btn btn-default" type="submit">提交</button>
								<button class="btn btn-default" type="reset">重置</button>

							</div>
						</form>
					</div>

				</div>

			</div>
		</div>
	</div>
	<div class="container" id="footer">
		<div class="row">
			<div class="col-md-12"></div>
		</div>
	</div>
	<script type="text/javascript">
			$("#submitId")
					.click(
							function() {
								var v = $("#addform").serializeObject();
								$
										.ajax({
											url : "${pageContext.request.contextPath}/position/position/add",
											type : "POST",
											contentType : "application/json;charset=utf-8",
											data : JSON.stringify(v),
											success : function(result) {
												window.location.href = "${pageContext.request.contextPath}/position/position/list";
											},
											error : function(result) {
												alert("添加失败，请您重新填写！");
												
											}
										});
								return false;
							});
		});
	</script>
</body>

</html>